package com.kitty.game.bag.service.giftHandler;

import com.alibaba.fastjson.JSONObject;
import com.kitty.common.utils.SpringUtils;
import com.kitty.common.utils.EquipUtil;
import com.kitty.game.activity.service.boos.service.BoosService;
import com.kitty.game.attribute.AttrService;
import com.kitty.game.bag.message.RespIconCartoon;
import com.kitty.game.bag.model.GiftBagData;
import com.kitty.game.base.service.BagService;
import com.kitty.game.config.Equip;
import com.kitty.game.enter.FiedValue;
import com.kitty.game.equip.EquipDataPool;
import com.kitty.game.equip.model.*;
import com.kitty.game.equip.service.EquipService;
import com.kitty.game.equip.util.EquipProductUtil;
import com.kitty.game.npc.service.NewNpcService;
import com.kitty.game.onlinemall.service.MallService;
import com.kitty.game.role.model.Role;
import com.kitty.game.team.message.RespMsg;
import com.kitty.mina.message.MessagePusher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * 开启礼包得到 自定义/随机 首饰奖励  首饰礼盒
 */
@Component
public class JewelryGiftHandler extends GiftHandler {
    @Autowired
    AttrService attrService;
    @Autowired
    BagService bagService;
    @Autowired
    MallService mallService;

    @Override
    public void getReward(Role role, GiftBagData giftBagData) {
        //开启首饰礼包，弹出NPC 选择力法体敏装备
        String content = "首饰礼盒。[获得力首饰/shoushi_li][获得法首饰/shoushi_fa][获得体首饰/shoushi_ti][获得敏首饰/shoushi_min]";
        SpringUtils.getBean(NewNpcService.class).requestNpcContent(role, 15025,content);
    }

    public void sendReward(Role role, String msg) {
        RoleEquip roleEquip = SpringUtils.getBean(EquipService.class).getRoleEquipByName(role, "首饰礼盒");
        //删除叠加物品
        if (SpringUtils.getBean(EquipService.class).delEquipNum(role, roleEquip, 1) <= 0) {
            return;
        }

        int roleLevel = role.getLevel();
        int level= EquipProductUtil.getLevelStage(roleLevel);

        int type=0;
        switch (msg){
            case "shoushi_li":
                type=1;
                break;
            case "shoushi_fa":
                type=2;
                break;
            case "shoushi_ti":
                type=3;
                break;
            case "shoushi_min":
                type=4;
                break;
        }
        String[] shoushi = getShouShiByLevel(level, type);
        //给4个首饰
        SpringUtils.getEquipService().getJewelryNew(role, shoushi[0].substring(0,shoushi[0].indexOf("(")), 1, shoushi[0],false);
        SpringUtils.getEquipService().getJewelryNew(role, shoushi[1].substring(0,shoushi[1].indexOf("(")), 1, shoushi[1],false);
        SpringUtils.getEquipService().getJewelryNew(role, shoushi[2].substring(0,shoushi[2].indexOf("(")), 1, shoushi[2],false);
        SpringUtils.getEquipService().getJewelryNew(role, shoushi[2].substring(0,shoushi[2].indexOf("(")), 1, shoushi[2],false);

    }

    public static void main(String[] args) {
        String[] shouShiByLevel = getShouShiByLevel(130, 1);
        for (String s : shouShiByLevel) {
            System.out.println(s);
        }
    }
    private static String[] getShouShiByLevel(int level,int type){
        String name[] = new String[4];
        if(level == 80){
            name[0]="七龙珠";
            name[1]="天机锁链";
            name[2]="闭月双环";
            if(type == 1 || type == 2 || type == 3 || type == 4){
                name[0] = name[0] + "(x5)";
                name[1] = name[1] + "(x5)";
                name[2] = name[2] + "(x5)";
            }
        }else if(level == 90){
            name[0]="金蟾宝囊";
            name[1]="秘魔灵珠";
            name[2]="三清手镯";
            if(type == 1 || type == 2 || type == 3 || type == 4){
                name[0] = name[0] + "(x5+2*x5)";
                name[1] = name[1] + "(x5+2*x5)";
                name[2] = name[2] + "(x5+2*x5)";
            }
        }else if(level == 100){
            name[0]="通灵宝玉";
            name[1]="金碧莲花";
            name[2]="天星奇光";
            if(type == 1 || type == 2 || type == 3 || type == 4){
                name[0] = name[0] + "(x5+2*x5";
                name[1] = name[1] + "(x5+2*x5";
                name[2] = name[2] + "(x5+2*x5";
            }
            if(type == 1 ){
                name[0] = name[0] + "+25力)";
                name[1] = name[1] + "+25力)";
                name[2] = name[2] + "+25力)";
            }else if(type == 2 ){
                name[0] = name[0] + "+25灵)";
                name[1] = name[1] + "+25灵)";
                name[2] = name[2] + "+25灵)";
            }else if(type == 3 ){
                name[0] = name[0] + "+25体)";
                name[1] = name[1] + "+25体)";
                name[2] = name[2] + "+25体)";
            }else if(type == 4 ){
                name[0] = name[0] + "+25敏)";
                name[1] = name[1] + "+25敏)";
                name[2] = name[2] + "+25敏)";
            }

        }else if(level == 110){
            name[0]="寒玉龙勾";
            name[1]="流光绝影";
            name[2]="碎梦涵光";
            if(type == 1 || type == 2 || type == 3 || type == 4){
                name[0] = name[0] + "(x5+2*x5";
                name[1] = name[1] + "(x5+2*x5";
                name[2] = name[2] + "(x5+2*x5";
            }
            if(type == 1 ){
                name[0] = name[0] + "+27力+2*27力)";
                name[1] = name[1] + "+27力+2*27力)";
                name[2] = name[2] + "+27力+2*27力)";
            }else if(type == 2 ){
                name[0] = name[0] + "+27灵+2*27灵)";
                name[1] = name[1] + "+27灵+2*27灵)";
                name[2] = name[2] + "+27灵+2*27灵)";
            }else if(type == 3 ){
                name[0] = name[0] + "+27体+2*27体)";
                name[1] = name[1] + "+27体+2*27体)";
                name[2] = name[2] + "+27体+2*27体)";
            }else if(type == 4 ){
                name[0] = name[0] + "+27敏+2*27敏)";
                name[1] = name[1] + "+27敏+2*27敏)";
                name[2] = name[2] + "+27敏+2*27敏)";
            }
        }else if(level == 120){
            name[0]="八宝如意";
            name[1]="五蕴悯光";
            name[2]="九天霜华";
            if(type == 1 || type == 2 || type == 3 || type == 4){
                name[0] = name[0] + "(x5+2*x5";
                name[1] = name[1] + "(x5+2*x5";
                name[2] = name[2] + "(x5+2*x5";
            }
            if(type == 1 ){
                name[0] = name[0] + "+30力+2*30力+30敏)";
                name[1] = name[1] + "+30力+2*30力+30敏)";
                name[2] = name[2] + "+30力+2*30力+30敏)";
            }else if(type == 2 ){
                name[0] = name[0] + "+30灵+2*30灵+30敏)";
                name[1] = name[1] + "+30灵+2*30灵+30敏)";
                name[2] = name[2] + "+30灵+2*30灵+30敏)";
            }else if(type == 3 ){
                name[0] = name[0] + "+30体+2*30体+30敏)";
                name[1] = name[1] + "+30体+2*30体+30敏)";
                name[2] = name[2] + "+30体+2*30体+30敏)";
            }else if(type == 4 ){
                name[0] = name[0] + "+30敏+2*30敏+10技)";
                name[1] = name[1] + "+30敏+2*30敏+10技)";
                name[2] = name[2] + "+30敏+2*30敏+10技)";
            }
        }else if(level == 130){
            name[0]="游火灵焰";
            name[1]="千彩流光";
            name[2]="岚金火链";
            if(type == 1 || type == 2 || type == 3 || type == 4){
                name[0] = name[0] + "(x5+2*x5";
                name[1] = name[1] + "(x5+2*x5";
                name[2] = name[2] + "(x5+2*x5";
            }
            if(type == 1 ){
                name[0] = name[0] + "+32力+2*32力+32敏+2*32敏)";
                name[1] = name[1] + "+32力+2*32力+32敏+2*32敏)";
                name[2] = name[2] + "+32力+2*32力+32敏+2*32敏)";
            }else if(type == 2 ){
                name[0] = name[0] + "+32灵+2*32灵+32敏+2*32敏)";
                name[1] = name[1] + "+32灵+2*32灵+32敏+2*32敏)";
                name[2] = name[2] + "+32灵+2*32灵+32敏+2*32敏)";
            }else if(type == 3 ){
                name[0] = name[0] + "+32体+2*32体+32敏+2*32敏)";
                name[1] = name[1] + "+32体+2*32体+32敏+2*32敏)";
                name[2] = name[2] + "+32体+2*32体+32敏+2*32敏)";
            }else if(type == 4 ){
                name[0] = name[0] + "+32敏+2*32敏+10技+2*10技)";
                name[1] = name[1] + "+32敏+2*32敏+10技+2*10技)";
                name[2] = name[2] + "+32敏+2*32敏+10技+2*10技)";
            }
        }else if(level == 140){
                name[0]="炫元玲珑";
                name[1]="掠虹宝坠";
                name[2]="龙御七星";
                if(type == 1 || type == 2 || type == 3 || type == 4){
                    name[0] = name[0] + "(x5+2*x5";
                    name[1] = name[1] + "(x5+2*x5";
                    name[2] = name[2] + "(x5+2*x5";
                }
                if(type == 1 ){
                    name[0] = name[0] + "+35力+2*35力+35敏+2*35敏+10技)";
                    name[1] = name[1] + "+35力+2*35力+35敏+2*35敏+10技)";
                    name[2] = name[2] + "+35力+2*35力+35敏+2*35敏+10技)";
                }else if(type == 2 ){
                    name[0] = name[0] + "+35灵+2*35灵+35敏+2*35敏+10技)";
                    name[1] = name[1] + "+35灵+2*35灵+35敏+2*35敏+10技)";
                    name[2] = name[2] + "+35灵+2*35灵+35敏+2*35敏+10技)";
                }else if(type == 3 ){
                    name[0] = name[0] + "+35体+2*32体+32敏+2*32敏+10技)";
                    name[1] = name[1] + "+35体+2*35体+35敏+2*35敏+10技)";
                    name[2] = name[2] + "+35体+2*35体+35敏+2*35敏+10技)";
                }else if(type == 4 ){
                    name[0] = name[0] + "+35敏+2*35敏+10技+2*10技+35体)";
                    name[1] = name[1] + "+35敏+2*35敏+10技+2*10技+35体)";
                    name[2] = name[2] + "+35敏+2*35敏+10技+2*10技+35体)";
                }
        }else if(level == 150){
            name[0]="七杀固元";
            name[1]="破军捆灵";
            name[2]="贪狼破日";
            if(type == 1 || type == 2 || type == 3 || type == 4){
                name[0] = name[0] + "(x5+2*x5";
                name[1] = name[1] + "(x5+2*x5";
                name[2] = name[2] + "(x5+2*x5";
            }
            if(type == 1 ){
                name[0] = name[0] + "+37力+2*37力+37敏+2*37敏+10技+2*10技)";
                name[1] = name[1] + "+37力+2*37力+37敏+2*37敏+10技+2*10技)";
                name[2] = name[2] + "+37力+2*37力+37敏+2*37敏+10技+2*10技)";
            }else if(type == 2 ){
                name[0] = name[0] + "+37灵+2*37灵+37敏+2*37敏+10技+2*10技)";
                name[1] = name[1] + "+37灵+2*37灵+37敏+2*37敏+10技+2*10技)";
                name[2] = name[2] + "+37灵+2*37灵+37敏+2*37敏+10技+2*10技)";
            }else if(type == 3 ){
                name[0] = name[0] + "+37体+2*37体+37敏+2*37敏+10技+2*10技)";
                name[1] = name[1] + "+37体+2*37体+37敏+2*37敏+10技+2*10技)";
                name[2] = name[2] + "+37体+2*37体+37敏+2*37敏+10技+2*10技)";
            }else if(type == 4 ){
                name[0] = name[0] + "+37敏+2*37敏+10技+2*10技+37体+2*37体)";
                name[1] = name[1] + "+37敏+2*37敏+10技+2*10技+37体+2*37体)";
                name[2] = name[2] + "+37敏+2*37敏+10技+2*10技+37体+2*37体)";
            }
        }else if(level == 160){
            name[0]="洛神回雪";
            name[1]="菩提镜明";
            name[2]="屠龙封魔";
            if(type == 1 || type == 2 || type == 3 || type == 4){
                name[0] = name[0] + "(x5+2*x5";
                name[1] = name[1] + "(x5+2*x5";
                name[2] = name[2] + "(x5+2*x5";
            }
            if(type == 1 ){
                name[0] = name[0] + "+40力+2*40力+40敏+2*40敏+10技+2*10技)";
                name[1] = name[1] + "+40力+2*40力+40敏+2*40敏+10技+2*10技)";
                name[2] = name[2] + "+40力+2*40力+40敏+2*40敏+10技+2*10技)";
            }else if(type == 2 ){
                name[0] = name[0] + "+40灵+2*40灵+40敏+2*40敏+10技+2*10技)";
                name[1] = name[1] + "+40灵+2*40灵+40敏+2*40敏+10技+2*10技)";
                name[2] = name[2] + "+40灵+2*40灵+40敏+2*40敏+10技+2*10技)";
            }else if(type == 3 ){
                name[0] = name[0] + "+40体+2*40体+40敏+2*40敏+10技+2*10技)";
                name[1] = name[1] + "+40体+2*40体+40敏+2*40敏+10技+2*10技)";
                name[2] = name[2] + "+40体+2*40体+40敏+2*40敏+10技+2*10技)";
            }else if(type == 4 ){
                name[0] = name[0] + "+40敏+2*40敏+10技+2*10技+40体+2*40体)";
                name[1] = name[1] + "+40敏+2*40敏+10技+2*10技+40体+2*40体)";
                name[2] = name[2] + "+40敏+2*40敏+10技+2*10技+40体+2*40体)";
            }
        }else if(level == 170){
            name[0]="景云烛日";
            name[1]="和光同尘";
            name[2]="九霞朝真";
            if(type == 1 || type == 2 || type == 3 || type == 4){
                name[0] = name[0] + "(x5+2*x5";
                name[1] = name[1] + "(x5+2*x5";
                name[2] = name[2] + "(x5+2*x5";
            }
            if(type == 1 ){
                name[0] = name[0] + "+42力+2*42力+42敏+2*42敏+10技+2*10技)";
                name[1] = name[1] + "+42力+2*42力+42敏+2*42敏+10技+2*10技)";
                name[2] = name[2] + "+42力+2*42力+42敏+2*42敏+10技+2*10技)";
            }else if(type == 2 ){
                name[0] = name[0] + "+42灵+2*42灵+42敏+2*42敏+10技+2*10技)";
                name[1] = name[1] + "+42灵+2*42灵+42敏+2*42敏+10技+2*10技)";
                name[2] = name[2] + "+42灵+2*42灵+42敏+2*42敏+10技+2*10技)";
            }else if(type == 3 ){
                name[0] = name[0] + "+42体+2*42体+42敏+2*42敏+10技+2*10技)";
                name[1] = name[1] + "+42体+2*42体+42敏+2*42敏+10技+2*10技)";
                name[2] = name[2] + "+42体+2*42体+42敏+2*42敏+10技+2*10技)";
            }else if(type == 4 ){
                name[0] = name[0] + "+42敏+2*42敏+10技+2*10技+42体+2*42体)";
                name[1] = name[1] + "+42敏+2*42敏+10技+2*10技+42体+2*42体)";
                name[2] = name[2] + "+42敏+2*42敏+10技+2*10技+42体+2*42体)";
            }
        }
        return name;
    }


}
